\(\int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx\) [15]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 117 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=2 a^2 (A-i B) x+\frac {2 a^2 (A-i B) \cot (c+d x)}{d}-\frac {a^2 (4 i A+3 B) \cot ^2(c+d x)}{6 d}-\frac {2 a^2 (i A+B) \log (\sin (c+d x))}{d}-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d} \]

[Out]

2*a^2*(A-I*B)*x+2*a^2*(A-I*B)*cot(d*x+c)/d-1/6*a^2*(4*I*A+3*B)*cot(d*x+c)^2/d-2*a^2*(I*A+B)*ln(sin(d*x+c))/d-1
/3*A*cot(d*x+c)^3*(a^2+I*a^2*tan(d*x+c))/d

Rubi [A] (verified)

Time = 0.45 (sec) , antiderivative size = 117, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3674, 3672, 3610, 3612, 3556} \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {a^2 (3 B+4 i A) \cot ^2(c+d x)}{6 d}+\frac {2 a^2 (A-i B) \cot (c+d x)}{d}-\frac {2 a^2 (B+i A) \log (\sin (c+d x))}{d}+2 a^2 x (A-i B)-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d} \]

[In]

Int[Cot[c + d*x]^4*(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

2*a^2*(A - I*B)*x + (2*a^2*(A - I*B)*Cot[c + d*x])/d - (a^2*((4*I)*A + 3*B)*Cot[c + d*x]^2)/(6*d) - (2*a^2*(I*
A + B)*Log[Sin[c + d*x]])/d - (A*Cot[c + d*x]^3*(a^2 + I*a^2*Tan[c + d*x]))/(3*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3610

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b
*c - a*d)*((a + b*Tan[e + f*x])^(m + 1)/(f*(m + 1)*(a^2 + b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e +
f*x])^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c
 - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3672

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e
_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*c - a*d)*(A*b - a*B)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2
+ b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[a*A*c + b*B*c + A*b*d - a*B*d - (A*b*
c - a*B*c - a*A*d - b*B*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0]
 && LtQ[m, -1] && NeQ[a^2 + b^2, 0]

Rule 3674

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-a^2)*(B*c - A*d)*(a + b*Tan[e + f*x])^(m - 1)*((c + d*Tan[e + f*x]
)^(n + 1)/(d*f*(b*c + a*d)*(n + 1))), x] - Dist[a/(d*(b*c + a*d)*(n + 1)), Int[(a + b*Tan[e + f*x])^(m - 1)*(c
 + d*Tan[e + f*x])^(n + 1)*Simp[A*b*d*(m - n - 2) - B*(b*c*(m - 1) + a*d*(n + 1)) + (a*A*d*(m + n) - B*(a*c*(m
 - 1) + b*d*(n + 1)))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && E
qQ[a^2 + b^2, 0] && GtQ[m, 1] && LtQ[n, -1]

Rubi steps \begin{align*} \text {integral}& = -\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d}+\frac {1}{3} \int \cot ^3(c+d x) (a+i a \tan (c+d x)) (a (4 i A+3 B)-a (2 A-3 i B) \tan (c+d x)) \, dx \\ & = -\frac {a^2 (4 i A+3 B) \cot ^2(c+d x)}{6 d}-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d}+\frac {1}{3} \int \cot ^2(c+d x) \left (-6 a^2 (A-i B)-6 a^2 (i A+B) \tan (c+d x)\right ) \, dx \\ & = \frac {2 a^2 (A-i B) \cot (c+d x)}{d}-\frac {a^2 (4 i A+3 B) \cot ^2(c+d x)}{6 d}-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d}+\frac {1}{3} \int \cot (c+d x) \left (-6 a^2 (i A+B)+6 a^2 (A-i B) \tan (c+d x)\right ) \, dx \\ & = 2 a^2 (A-i B) x+\frac {2 a^2 (A-i B) \cot (c+d x)}{d}-\frac {a^2 (4 i A+3 B) \cot ^2(c+d x)}{6 d}-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d}-\left (2 a^2 (i A+B)\right ) \int \cot (c+d x) \, dx \\ & = 2 a^2 (A-i B) x+\frac {2 a^2 (A-i B) \cot (c+d x)}{d}-\frac {a^2 (4 i A+3 B) \cot ^2(c+d x)}{6 d}-\frac {2 a^2 (i A+B) \log (\sin (c+d x))}{d}-\frac {A \cot ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{3 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.66 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.22 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=a^2 \left (\frac {2 A \cot (c+d x)}{d}-\frac {2 i B \cot (c+d x)}{d}-\frac {i A \cot ^2(c+d x)}{d}-\frac {B \cot ^2(c+d x)}{2 d}-\frac {A \cot ^3(c+d x)}{3 d}-\frac {2 i A \log (\tan (c+d x))}{d}-\frac {2 B \log (\tan (c+d x))}{d}+\frac {2 i A \log (i+\tan (c+d x))}{d}+\frac {2 B \log (i+\tan (c+d x))}{d}\right ) \]

[In]

Integrate[Cot[c + d*x]^4*(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

a^2*((2*A*Cot[c + d*x])/d - ((2*I)*B*Cot[c + d*x])/d - (I*A*Cot[c + d*x]^2)/d - (B*Cot[c + d*x]^2)/(2*d) - (A*
Cot[c + d*x]^3)/(3*d) - ((2*I)*A*Log[Tan[c + d*x]])/d - (2*B*Log[Tan[c + d*x]])/d + ((2*I)*A*Log[I + Tan[c + d
*x]])/d + (2*B*Log[I + Tan[c + d*x]])/d)

Maple [A] (verified)

Time = 0.25 (sec) , antiderivative size = 104, normalized size of antiderivative = 0.89

method result size
parallelrisch \(-\frac {2 a^{2} \left (\left (-\frac {i A}{2}-\frac {B}{2}\right ) \ln \left (\sec ^{2}\left (d x +c \right )\right )+\left (i A +B \right ) \ln \left (\tan \left (d x +c \right )\right )+\frac {7 A \left (\cot ^{3}\left (d x +c \right )\right )}{6}+\left (\cot ^{2}\left (d x +c \right )\right ) \left (\frac {i A}{2}+\frac {B}{4}\right )+\left (-A \left (\csc ^{2}\left (d x +c \right )\right )+i B \right ) \cot \left (d x +c \right )+x d \left (i B -A \right )\right )}{d}\) \(104\)
derivativedivides \(\frac {-A \,a^{2} \left (-\cot \left (d x +c \right )-d x -c \right )-B \,a^{2} \ln \left (\sin \left (d x +c \right )\right )+2 i A \,a^{2} \left (-\frac {\left (\cot ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\sin \left (d x +c \right )\right )\right )+2 i B \,a^{2} \left (-\cot \left (d x +c \right )-d x -c \right )+A \,a^{2} \left (-\frac {\left (\cot ^{3}\left (d x +c \right )\right )}{3}+\cot \left (d x +c \right )+d x +c \right )+B \,a^{2} \left (-\frac {\left (\cot ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\sin \left (d x +c \right )\right )\right )}{d}\) \(142\)
default \(\frac {-A \,a^{2} \left (-\cot \left (d x +c \right )-d x -c \right )-B \,a^{2} \ln \left (\sin \left (d x +c \right )\right )+2 i A \,a^{2} \left (-\frac {\left (\cot ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\sin \left (d x +c \right )\right )\right )+2 i B \,a^{2} \left (-\cot \left (d x +c \right )-d x -c \right )+A \,a^{2} \left (-\frac {\left (\cot ^{3}\left (d x +c \right )\right )}{3}+\cot \left (d x +c \right )+d x +c \right )+B \,a^{2} \left (-\frac {\left (\cot ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\sin \left (d x +c \right )\right )\right )}{d}\) \(142\)
risch \(\frac {4 i a^{2} B c}{d}-\frac {4 a^{2} A c}{d}+\frac {2 a^{2} \left (15 i A \,{\mathrm e}^{4 i \left (d x +c \right )}+9 B \,{\mathrm e}^{4 i \left (d x +c \right )}-18 i A \,{\mathrm e}^{2 i \left (d x +c \right )}-15 B \,{\mathrm e}^{2 i \left (d x +c \right )}+7 i A +6 B \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )^{3}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) B}{d}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) A}{d}\) \(145\)
norman \(\frac {\left (-2 i B \,a^{2}+2 A \,a^{2}\right ) x \left (\tan ^{3}\left (d x +c \right )\right )-\frac {A \,a^{2}}{3 d}+\frac {2 \left (-i B \,a^{2}+A \,a^{2}\right ) \left (\tan ^{2}\left (d x +c \right )\right )}{d}-\frac {\left (2 i A \,a^{2}+B \,a^{2}\right ) \tan \left (d x +c \right )}{2 d}}{\tan \left (d x +c \right )^{3}}+\frac {\left (i A \,a^{2}+B \,a^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}-\frac {2 \left (i A \,a^{2}+B \,a^{2}\right ) \ln \left (\tan \left (d x +c \right )\right )}{d}\) \(148\)

[In]

int(cot(d*x+c)^4*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

-2*a^2*((-1/2*I*A-1/2*B)*ln(sec(d*x+c)^2)+(I*A+B)*ln(tan(d*x+c))+7/6*A*cot(d*x+c)^3+cot(d*x+c)^2*(1/2*I*A+1/4*
B)+(-A*csc(d*x+c)^2+I*B)*cot(d*x+c)+x*d*(-A+I*B))/d

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 181, normalized size of antiderivative = 1.55 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (3 \, {\left (-5 i \, A - 3 \, B\right )} a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (6 i \, A + 5 \, B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (-7 i \, A - 6 \, B\right )} a^{2} + 3 \, {\left ({\left (i \, A + B\right )} a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, {\left (-i \, A - B\right )} a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (i \, A + B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (-i \, A - B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right )\right )}}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} - 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} - d\right )}} \]

[In]

integrate(cot(d*x+c)^4*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-2/3*(3*(-5*I*A - 3*B)*a^2*e^(4*I*d*x + 4*I*c) + 3*(6*I*A + 5*B)*a^2*e^(2*I*d*x + 2*I*c) + (-7*I*A - 6*B)*a^2
+ 3*((I*A + B)*a^2*e^(6*I*d*x + 6*I*c) + 3*(-I*A - B)*a^2*e^(4*I*d*x + 4*I*c) + 3*(I*A + B)*a^2*e^(2*I*d*x + 2
*I*c) + (-I*A - B)*a^2)*log(e^(2*I*d*x + 2*I*c) - 1))/(d*e^(6*I*d*x + 6*I*c) - 3*d*e^(4*I*d*x + 4*I*c) + 3*d*e
^(2*I*d*x + 2*I*c) - d)

Sympy [A] (verification not implemented)

Time = 0.57 (sec) , antiderivative size = 182, normalized size of antiderivative = 1.56 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=- \frac {2 i a^{2} \left (A - i B\right ) \log {\left (e^{2 i d x} - e^{- 2 i c} \right )}}{d} + \frac {14 i A a^{2} + 12 B a^{2} + \left (- 36 i A a^{2} e^{2 i c} - 30 B a^{2} e^{2 i c}\right ) e^{2 i d x} + \left (30 i A a^{2} e^{4 i c} + 18 B a^{2} e^{4 i c}\right ) e^{4 i d x}}{3 d e^{6 i c} e^{6 i d x} - 9 d e^{4 i c} e^{4 i d x} + 9 d e^{2 i c} e^{2 i d x} - 3 d} \]

[In]

integrate(cot(d*x+c)**4*(a+I*a*tan(d*x+c))**2*(A+B*tan(d*x+c)),x)

[Out]

-2*I*a**2*(A - I*B)*log(exp(2*I*d*x) - exp(-2*I*c))/d + (14*I*A*a**2 + 12*B*a**2 + (-36*I*A*a**2*exp(2*I*c) -
30*B*a**2*exp(2*I*c))*exp(2*I*d*x) + (30*I*A*a**2*exp(4*I*c) + 18*B*a**2*exp(4*I*c))*exp(4*I*d*x))/(3*d*exp(6*
I*c)*exp(6*I*d*x) - 9*d*exp(4*I*c)*exp(4*I*d*x) + 9*d*exp(2*I*c)*exp(2*I*d*x) - 3*d)

Maxima [A] (verification not implemented)

none

Time = 0.33 (sec) , antiderivative size = 111, normalized size of antiderivative = 0.95 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {12 \, {\left (d x + c\right )} {\left (A - i \, B\right )} a^{2} + 6 \, {\left (i \, A + B\right )} a^{2} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 12 \, {\left (i \, A + B\right )} a^{2} \log \left (\tan \left (d x + c\right )\right ) + \frac {12 \, {\left (A - i \, B\right )} a^{2} \tan \left (d x + c\right )^{2} + 3 \, {\left (-2 i \, A - B\right )} a^{2} \tan \left (d x + c\right ) - 2 \, A a^{2}}{\tan \left (d x + c\right )^{3}}}{6 \, d} \]

[In]

integrate(cot(d*x+c)^4*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

1/6*(12*(d*x + c)*(A - I*B)*a^2 + 6*(I*A + B)*a^2*log(tan(d*x + c)^2 + 1) - 12*(I*A + B)*a^2*log(tan(d*x + c))
 + (12*(A - I*B)*a^2*tan(d*x + c)^2 + 3*(-2*I*A - B)*a^2*tan(d*x + c) - 2*A*a^2)/tan(d*x + c)^3)/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 255 vs. \(2 (103) = 206\).

Time = 1.34 (sec) , antiderivative size = 255, normalized size of antiderivative = 2.18 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 6 i \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 3 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 27 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 24 i \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 96 \, {\left (-i \, A a^{2} - B a^{2}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + i\right ) + 48 \, {\left (-i \, A a^{2} - B a^{2}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right ) - \frac {-88 i \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 88 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 27 \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 24 i \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 6 i \, A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + A a^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3}}}{24 \, d} \]

[In]

integrate(cot(d*x+c)^4*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/24*(A*a^2*tan(1/2*d*x + 1/2*c)^3 - 6*I*A*a^2*tan(1/2*d*x + 1/2*c)^2 - 3*B*a^2*tan(1/2*d*x + 1/2*c)^2 - 27*A*
a^2*tan(1/2*d*x + 1/2*c) + 24*I*B*a^2*tan(1/2*d*x + 1/2*c) - 96*(-I*A*a^2 - B*a^2)*log(tan(1/2*d*x + 1/2*c) +
I) + 48*(-I*A*a^2 - B*a^2)*log(tan(1/2*d*x + 1/2*c)) - (-88*I*A*a^2*tan(1/2*d*x + 1/2*c)^3 - 88*B*a^2*tan(1/2*
d*x + 1/2*c)^3 - 27*A*a^2*tan(1/2*d*x + 1/2*c)^2 + 24*I*B*a^2*tan(1/2*d*x + 1/2*c)^2 + 6*I*A*a^2*tan(1/2*d*x +
 1/2*c) + 3*B*a^2*tan(1/2*d*x + 1/2*c) + A*a^2)/tan(1/2*d*x + 1/2*c)^3)/d

Mupad [B] (verification not implemented)

Time = 8.04 (sec) , antiderivative size = 93, normalized size of antiderivative = 0.79 \[ \int \cot ^4(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {\frac {A\,a^2}{3}-{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (2\,A\,a^2-B\,a^2\,2{}\mathrm {i}\right )+\mathrm {tan}\left (c+d\,x\right )\,\left (\frac {B\,a^2}{2}+A\,a^2\,1{}\mathrm {i}\right )}{d\,{\mathrm {tan}\left (c+d\,x\right )}^3}-\frac {a^2\,\mathrm {atan}\left (2\,\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )\,4{}\mathrm {i}}{d} \]

[In]

int(cot(c + d*x)^4*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i)^2,x)

[Out]

- ((A*a^2)/3 - tan(c + d*x)^2*(2*A*a^2 - B*a^2*2i) + tan(c + d*x)*(A*a^2*1i + (B*a^2)/2))/(d*tan(c + d*x)^3) -
 (a^2*atan(2*tan(c + d*x) + 1i)*(A*1i + B)*4i)/d